<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Prepares for a connection to a Z39.50 server</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.yaz-connect" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">yaz_connect</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.1, PECL yaz &gt;= 0.9.0)</p><p class="refpurpose"><span class="refname">yaz_connect</span> &mdash; <span class="dc-title">
   Prepares for a connection to a Z39.50 server
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.yaz-connect-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>yaz_connect</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$zurl</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$options</code></span>
  ] ) : <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">
   This function returns a connection resource on success, zero on
   failure.
  </p>
  <p class="para">
   <span class="function"><strong>yaz_connect()</strong></span> prepares for a connection to a
   Z39.50 server. 
   This function is non-blocking and does not attempt to establish
   a connection  - it merely prepares a connect to be performed later when
   <span class="function"><a href="yaz_wait.html" class="function">yaz_wait()</a></span> is called.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    The <a href="http://www.indexdata.dk/yazproxy/" class="link external">&raquo;&nbsp;YAZ proxy</a> is a
    freely available Z39.50 proxy.
   </p>
  </p></blockquote>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.yaz-connect-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">zurl</code></dt>

     <dd>

      <p class="para">
       A string that takes the form <em>host[:port][/database]</em>.
       If port is omitted, port 210 is used. If database is omitted 
       <em>Default</em> is used.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">options</code></dt>

     <dd>

      <p class="para">
       If given as a string, it is treated as the Z39.50 V2 authentication 
       string (OpenAuth).
      </p>
      <p class="para">
       If given as an array, the contents of the array serves as options.
       <dl>

        
         <dt>
user</dt>

         <dd>

          <p class="para">
           Username for authentication.
          </p>
         </dd>

        
        
         <dt>
group</dt>

         <dd>

          <p class="para">
           Group for authentication.
          </p>
         </dd>

        
        
         <dt>
password</dt>

          <dd>

           <p class="para">
            Password for authentication.
           </p>
          </dd>

        
        
         <dt>
cookie</dt>

         <dd>

          <p class="para">
           Cookie for session (YAZ proxy).
          </p>
         </dd>

        
        
         <dt>
proxy</dt>

         <dd>

          <p class="para">
           Proxy for connection (YAZ proxy).
          </p>
         </dd>

        
        
         <dt>
persistent</dt>

         <dd>

          <p class="para">
           A boolean. If <strong><code>TRUE</code></strong> the connection is persistent; If <strong><code>FALSE</code></strong> the
           connection is not persistent. By default connections are persistent.
          </p>
          <blockquote class="note"><p><strong class="note">Note</strong>: 
           <p class="para">
            If you open a persistent connection, you won&#039;t be able to close 
            it later with <span class="function"><a href="yaz_close.html" class="function">yaz_close()</a></span>.
           </p>
          </p></blockquote>
         </dd>

        
        
         <dt>
piggyback</dt>

         <dd>

          <p class="para">
           A boolean. If <strong><code>TRUE</code></strong> piggyback is enabled for searches; If <strong><code>FALSE</code></strong>
           piggyback is disabled. By default piggyback is enabled.
          </p>
          <p class="para">
           Enabling piggyback is more efficient and usually saves a 
           network-round-trip for first time fetches of records. However, a 
           few Z39.50 servers do not support piggyback or they ignore element
           set names. For those, piggyback should be disabled.
          </p>
         </dd>

        
        
         <dt>
charset</dt>

         <dd>

          <p class="para">
           A string that specifies character set to be used in Z39.50 
           language and character set negotiation. Use strings such as:
           <em>ISO-8859-1</em>, <em>UTF-8</em>, 
           <em>UTF-16</em>.
          </p>
          <p class="para">
           Most Z39.50 servers do not support this feature (and thus, this is
           ignored). Many servers use the ISO-8859-1 encoding for queries and
           messages. MARC21/USMARC records are not affected by this setting.
          </p>
         </dd>

        

        
         <dt>
preferredMessageSize</dt>

         <dd>

          <p class="para">
           An integer that specifies the maximum byte size of all records
           to be returned by a target during retrieval. See the
           <a href="http://www.loc.gov/z3950/agency/markup/04.html#3.2.1.1.4" class="link external">&raquo;&nbsp;Z39.50 standard</a> for more
           information.
          </p>
          <blockquote class="note"><p><strong class="note">Note</strong>: 
           <p class="para">
            This option is supported in PECL YAZ 1.0.5 or later.
           </p>
          </p></blockquote>
         </dd>

        

        
         <dt>
maximumRecordSize</dt>

         <dd>

          <p class="para">
           An integer that specifies the maximum byte size of a single record
           to be returned by a target during retrieval. This
           entity is referred to as Exceptional-record-size in the
          <a href="http://www.loc.gov/z3950/agency/markup/04.html#3.2.1.1.4" class="link external">&raquo;&nbsp;Z39.50 standard</a>.
          </p>
          <blockquote class="note"><p><strong class="note">Note</strong>: 
           <p class="para">
            This option is supported in PECL YAZ 1.0.5 or later.
           </p>
          </p></blockquote>
         </dd>

        

       </dl>

      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.yaz-connect-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   A connection resource on success, <strong><code>FALSE</code></strong> on error.
  </p>
 </div>

 <div class="refsect1 changelog" id="refsect1-function.yaz-connect-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>4.1.0</td>
       <td>
        The parameter <code class="parameter">options</code> was added.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.yaz-connect-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="yaz_close.html" class="function" rel="rdfs-seeAlso">yaz_close()</a> - Close YAZ connection</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>